package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.urgentTeardownStandardPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:urgentTeardownStandardMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/10/15 15:56
 * @Version 1.0
 */
@Mapper
public interface urgentTeardownStandardMapp {
    //插入一行特急分解检测标准
    @DS("newMscLowCodeFormal")
    @Insert("insert into ddm_urgent_teardown_standard (" +
            "id, create_time, update_time, " +
            "creator, process_status, sys_update_user, " +
            "sys_audit_user, sys_audit_time, sys_deleted, " +
            "part_number, part_name, measurement_project, " +
            "category, standard_value, upper_tolerance, " +
            "lower_tolerance, standard_setter, approver, " +
            "measurement_place, engine_model) " +
            "VALUES (" +
            "#{id}, #{create_time}, #{update_time}, " +
            "#{creator}, #{process_status}, #{sys_update_user}, " +
            "#{sys_audit_user}, #{sys_audit_time}, #{sys_deleted}, " +
            "#{part_number}, #{part_name}, #{measurement_project}, " +
            "#{category}, #{standard_value}, #{upper_tolerance}, " +
            "#{lower_tolerance}, #{standard_setter}, #{approver}, " +
            "#{measurement_place}, #{engine_model})")
    void insertOne(urgentTeardownStandardPojo pojo);

    //修改一行特急分解检测标准
    @DS("newMscLowCodeFormal")
    @Update("update ddm_urgent_teardown_standard " +
            "set " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +
            "process_status=#{process_status}, " +
            "sys_update_user=#{sys_update_user}, "+
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "engine_model=#{engine_model}, " +
            "part_number=#{part_number}, " +
            "part_name=#{part_name}, " +
            "measurement_project=#{measurement_project}, " +
            "category=#{category}, "+
            "standard_value=#{standard_value}," +
            "upper_tolerance=#{upper_tolerance}, "+
            "lower_tolerance=#{lower_tolerance}, " +
            "standard_setter=#{standard_setter}, " +
            "approver=#{approver}, " +
            "measurement_place=#{measurement_place} " +
            "where id=#{id}")
    void editOneById(urgentTeardownStandardPojo pojo);

    //查询所有特急分解检测标准
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_standard where sys_deleted=0 order by create_time ASC")
    List<urgentTeardownStandardPojo> queryAll();

    //查询一个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_standard " +
            "where sys_deleted=0 and ${fieldName}=#{fieldValue}")
    List<urgentTeardownStandardPojo> queryOneField(String fieldName, String fieldValue);

    //根据分页查询特急分解检测标准
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_standard where " +
            "sys_deleted=0 " +
            "order by create_time ASC " +
            "limit #{startRow}, #{size}")
    List<urgentTeardownStandardPojo> queryByPage(Integer startRow, Integer size);
    //查询所有特急分解检测标准总条数
    @DS("newMscLowCodeFormal")
    @Select("SELECT COUNT(*) FROM ddm_urgent_teardown_standard where sys_deleted=0")
    Integer queryQuantity();
}
